﻿@using Bonobo.Git.Server.Extensions
@model RepositoryTreeDetailModel
@{
    Layout = "~/Views/Repository/_RepositoryLayout.cshtml";
    ViewBag.Title = Resources.Repository_Tree_Title;
}
@if (Model != null)
{
    @Html.Partial("_BranchSwitcher")
    @Html.Partial("_AddressBar")

    <div class="blob">
        @{
            <div class="controls">
                <span>@(Model.IsText ? Model.Text.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None).Length + " lines |" : "") @FileDisplayHandler.GetFileSizeString(Model.Data.LongLength)</span>
                <a href="@Url.Action("Blame", new { id=ViewBag.ID, encodedName = PathEncoder.Encode(Model.TreeName), encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true)})"><i class="fa fa-comments"></i> @Resources.Repository_Tree_Blame</a>
                <a href="@Url.Action("History", new { id=ViewBag.ID, encodedName = PathEncoder.Encode(Model.TreeName), encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true)})"><i class="fa fa-history"></i> @Resources.Repository_Tree_History</a>
                <a href="@Url.Action("Raw", new { id=ViewBag.ID, encodedName = PathEncoder.Encode(Model.TreeName), encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true), display = true })"><i class="fa fa-file-text"></i> @Resources.Repository_Tree_RawDisplay</a>
                <a href="@Url.Action("Raw", new { id=ViewBag.ID, encodedName = PathEncoder.Encode(Model.TreeName), encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true) })"><i class="fa fa-download"></i> @Resources.Repository_Tree_Download</a>
            </div>
        }
        @if (Model.IsImage)
        {
            <img class="fileImage" alt="@Model.Name" src="@Url.Action("Raw", new { id=ViewBag.ID, encodedName = PathEncoder.Encode(Model.TreeName), encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true) })" />
        }
        else if (Model.IsText && Model.IsMarkdown)
        {
            <div class="markdown">@Html.MarkdownToHtml(Model.Text)</div>
        }
        else if (Model.IsText)
        {
            <pre><code class="@Model.TextBrush">@Model.Text</code></pre>
        }
        else
        {
            <pre><code>@Resources.Repository_Tree_PreviewNotSupported</code></pre>
        }
    </div>
}

@section scripts 
{
    <script>hljs.configure({tabReplace:'    '});hljs.initHighlightingOnLoad();</script>
}
